tinymce.PluginManager.add('letterspacing', function(editor, url) {
    var pluginName='字间距';
    var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
    var letterspacing_val = editor.getParam('letterspacing_val', '0px 0.25px 0.5px 1px 1.5px 2px 2.5px 3px 4px 5px');

    editor.on('init', function() {
        editor.formatter.register({
        	letterspacing: {
                selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table',
                styles: { 'letter-spacing': '%value' }
            }
        });
    });

    var doAct = function (value) {
        editor.formatter.apply('letterspacing', { value: value });
        editor.fire('change', {});
    };
    
    editor.ui.registry.addMenuButton('letterspacingselect', {
        text: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><image width="24" height="24" x="0" y="0"'+
        	'href="'+
	        'AAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElN'+
	        'RQfjBwQRFRUmykNzAAABTklEQVQ4y62UzXGDMBBGH5nkjA/ac+jApIN0YDoIJVBAnB+ngaQDShAd'+
	        '2B1QQnLWBVegHNAIG4nY2NkdZjTS6rHfwm6iLJiEkckCDUBrKgKT6B1nyiprGbsqlXW+iJxG7/R+'+
	        'M/GeIrI6y6JAyVgBzb8BHaSmAVaSXQ8sgb3R7sPMyjEClIwloN3T46/KsM9Ig+logOUc0TFg5QTj'+
	        'c5whOgBKzr0HXSA6zLA8AA2i8/h1eRZ74G+EnaK+lVVd0DOfU52i1r6n3i2W26jgVh79VueqWMVz'+
	        'NB8CG2BjXgGS4+EgNU8TxXkwrY8aDQdZc2de+vUY2JFOAL+GufPXtDmSLAUpsGM7iqpIp0WP7KjA'+
	        'tbLKqjwYV/1+MX98FcDPUCtv2p+etAOgE6zDIKPZXwB0v3QdjdNAKmcgPVAWrCYEzxI9fOWMXVxw'+
	        'L1p2QHYa+AupichtKDMNPgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wNy0wNFQwOToyMToyMSsw'+
	        'ODowMFvAJvIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDctMDRUMDk6MjE6MjErMDg6MDAqnZ5O'+
	        'AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==" /></svg>',
        tooltip: pluginName,
        fetch: function(callback) {
            var dom = editor.dom;
            var blocks = editor.selection.getSelectedBlocks();
            var lhv = 0;
            global$1.each(blocks, function(block) {
                if(lhv==0){
                    lhv = dom.getStyle(block,'letter-spacing') ? dom.getStyle(block,'letter-spacing') : 0;
                }
            });

            var items = letterspacing_val.split(' ').map(function(item){
                var text = item;
                var value = item;
                return {
                    type: 'togglemenuitem',
                    text: text,
                    active : lhv==value ? true :false,
                    onAction: function() {
                        doAct(value);
                    }
                };
            });
            callback(items);
        }
    });

    return {
        getMetadata: function () {
            return  {
                name: pluginName,
                url: "http://tinymce.ax-z.cn/more-plugins/lineheight.php",
            };
        }
    };
});